package tienmanh.gs.goldminer.sprite;

import org.andengine.entity.IEntity;
import org.andengine.entity.modifier.AlphaModifier;
import org.andengine.entity.modifier.LoopEntityModifier;
import org.andengine.entity.modifier.PathModifier;
import org.andengine.entity.modifier.SequenceEntityModifier;
import org.andengine.entity.modifier.IEntityModifier.IEntityModifierListener;
import org.andengine.entity.primitive.Line;
import org.andengine.entity.text.Text;
import org.andengine.entity.text.TextOptions;
import org.andengine.opengl.font.IFont;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.util.math.MathUtils;
import org.andengine.util.modifier.IModifier;

import tienmanh.gs.goldminer.manager.ResourcesManager;
import tienmanh.gs.goldminer.manager.SceneManager;
import tienmanh.gs.goldminer.scene.GameScene;
import tienmanh.gs.goldminer.sprite.shop.FrzeeTime;

public class MyText extends Text
{
	Line line;
	Hook hook;
public MyText(float pX, float pY, IFont pFont, CharSequence pText,
			int pCharactersMaximum, TextOptions pTextOptions,
			VertexBufferObjectManager pVertexBufferObjectManager, float paramFloat3, float paramFloat4, int paramInt , int value , Line line,Hook hook) {
		super(pX, pY, pFont, pText, pCharactersMaximum, pTextOptions,
				pVertexBufferObjectManager);
		// TODO Auto-generated constructor stub
		setColor(1.0F, 1.0F, 0.0F);
	    moveText(pX, pY, paramFloat3, paramFloat4,value);
	    this.line = line;
	    this.hook = hook;
	}

  public void moveText(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4 , final int value)
  {
    final SequenceEntityModifier entityModifier = new SequenceEntityModifier(
			new IEntityModifierListener() {
				@Override
				public void onModifierStarted(
						final IModifier<IEntity> pModifier,
						final IEntity pItem) {
				}
//
				@Override
				public void onModifierFinished(
						final IModifier<IEntity> pEntityModifier,
						final IEntity pEntity) {
					
					System.out.println("sadasdsad"+GameScene.getInstace().isPearl);
					if(GameScene.arrayGolds.get(value) != null && !GameScene.getInstace().isPearl)
					{
					GameScene.sceneHUD.detachChild(GameScene.arrayGolds.get(value));
					GameScene.arrayGolds.set(value, null);
					}
					if(GameScene.getInstace().isPearl) {
						GameScene.getInstace().isPearl = false;
						GameScene.sceneHUD.detachChild(GameScene.getInstace().pearl);
					}
					GameScene.sceneHUD.detachChild(MyText.this);
				    GameScene.getInstace().isPull = false;
				    hook.setVisible(true);
				    hook.unPullHook();
					hook.Rotate();
					GameScene.miner.stopAnimation();
					if(GameScene.isMinerRunning)  GameScene.miner.MinerRun();
					GameScene.pullGold = false;
          			GameScene.getInstace().isTouch = true;
					GameScene.getInstace().waitingThrowHook(hook);
					GameScene.tvMoney.setText(""+GameScene.money);
				}
			}, new PathModifier(1.0F, new PathModifier.Path(3).to(paramFloat1, paramFloat2).to(300, paramFloat4).to(paramFloat3, paramFloat4)));
	    registerEntityModifier(entityModifier);
  }
}

